package cn.com.elite;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;

public class Test {
	public static void main(String[] args){
		for(int i=0;i<1000;i++){
			System.out.println(i);
			doGet();
		}
	}
	 public static void doGet(){
		 try {
		    URL url=new URL("http://localhost:8080/EliteRecordFtp/EliteRecordFtpService");
			HttpURLConnection conn=(HttpURLConnection)url.openConnection();
			conn.setRequestMethod("POST");
			conn.setUseCaches(false);
			conn.setInstanceFollowRedirects(true);
			conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
			conn.setConnectTimeout(60000);
			conn.setReadTimeout(60000);
			conn.setDoOutput(true);
			conn.connect();
			DataOutputStream out=new DataOutputStream(conn.getOutputStream()); 
			out.writeBytes("&FtpURL=ftp://192.168.2.43/123.mp3"); 
	        out.flush();
	        out.close();
			InputStream is=conn.getInputStream();
			File file = new File("C:\\123.mp3");
			FileOutputStream out1 = new FileOutputStream(file);
			byte [] buffer  =   new   byte [ 1024 ];
            while  (is.read(buffer)  >   0 )  {
               out1.write(buffer);
           } 
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	     
		 
	 }
}
